// pages/my/myorder/orderInfo/orderInfo.js
var app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    orderinfo: null,
    goodsinfo: {},
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    let currentOrderId = options.order_id;
    this.getOrderDetail(currentOrderId);
  },

  //获取订单详细信息
  getOrderDetail: function (targetId) {
    app.Ajax({
      url: '/api/index.php?app=order&act=detail',
      data: {
        order_id: targetId
      },
      success: (res) => {
        let goodsinfo = res.goods[0];
        this.setData({
          goodsinfo: {
            goods_id: goodsinfo.goods_id,
            goods_image: goodsinfo.goods_image,
            goods_name: goodsinfo.goods_name,
            quantity: goodsinfo.quantity,
            sell_price: goodsinfo.sell_price,
            rec_id: goodsinfo.rec_id,
            goods_attr_arr: [goodsinfo.sku_attr]
          }
        })
        this.setData({
          orderinfo: res
        })
      },
      fail: (err) => {
        console.log(err);
      }
    })
  },
})